////
////  MoreManagerViewController.m
////  JiuKuGospel
////
////  Created by jiukuyinyue on 15-11-9.
////  Copyright (c) 2015年 JiuKuForApp. All rights reserved.
////
//
//#import "MoreManagerViewController.h"
//#import "MoreManagerTableViewCell.h"
////#import "JKSongsMessStatus.h"
//
//@interface MoreManagerViewController ()<UITableViewDataSource, UITableViewDelegate>
//@property (nonatomic, strong)UITableView * managerTab;
//@property (nonatomic, strong)NSMutableArray * managerArr;   //被选中的数组
//@property (nonatomic, assign)BOOL selectAllBool;            //全选控制
//@end
//
//@implementation MoreManagerViewController
//
//- (BOOL)canBecomeFirstResponder{
//    return YES;
//}
//- (void)remoteControlReceivedWithEvent:(UIEvent *)event
//{
//    [[TheHomeManager shareTheHomeManager].playVC remoteControlReceivedWithEvent:event];
//}
//
//- (void)viewWillAppear:(BOOL)animated
//{
//    [super viewWillAppear:YES];
//    self.navigationController.navigationBar.hidden = NO;
//    FilesDownManage *filedownmanage = [FilesDownManage sharedFilesDownManage];
//    
////    [filedownmanage startLoad];
//    self.downingList=filedownmanage.downinglist;
//    
//    self.finishedList=filedownmanage.finishedlist;
//    //百度开始页面统计
//    [[BaiduMobStat defaultStat] pageviewStartWithName:@"moreManagerPage"];
//}
//- (void)viewDidDisappear:(BOOL)animated
//{
//    [super viewDidDisappear:YES];
//    //百度结束页面统计
//    [[BaiduMobStat defaultStat] pageviewEndWithName:@"moreManagerPage"];
//}
//
//- (void)viewDidLoad {
//    [super viewDidLoad];
//    // Do any additional setup after loading the view.
//    
//    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(reloadMessData) name:@"MoreManager" object:nil];
//    
//    
//    self.view.backgroundColor = [UIColor whiteColor];
//    //导航栏颜色
//    self.navigationController.navigationBar.barTintColor = JK_HUISE_LINE_COLOR;
//    self.navigationItem.title = @"批量操作";
//    //导航栏字体颜色
//    [self.navigationController.navigationBar setTitleTextAttributes:@{NSForegroundColorAttributeName:[UIColor blackColor]}];
//    
//    
//    UIButton * leftBtn = [UIButton buttonWithType:UIButtonTypeCustom];
//    leftBtn.frame = CGRectMake(0, 0, 60, 30);
//    [leftBtn setTitle:@"全选" forState:UIControlStateNormal];
//    [leftBtn setTitleColor:JK_RED_COLOR forState:UIControlStateNormal];
//    [leftBtn addTarget:self action:@selector(leftBtnAction) forControlEvents:UIControlEventTouchUpInside];
//    self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:leftBtn];
//    
//    UIButton * rightBtn = [UIButton buttonWithType:UIButtonTypeCustom];
//    rightBtn.frame = CGRectMake(0, 0, 60, 30);
//    [rightBtn setTitle:@"完成" forState:UIControlStateNormal];
//    [rightBtn setTitleColor:JK_RED_COLOR forState:UIControlStateNormal];
//    [rightBtn addTarget:self action:@selector(rightBtnAction) forControlEvents:UIControlEventTouchUpInside];
//    self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:rightBtn];
//    
//    
//    [self setupUI];
//}
//
//- (void)didReceiveMemoryWarning {
//    [super didReceiveMemoryWarning];
//    // Dispose of any resources that can be recreated.
//}
//
//- (void)setupUI
//{
//    
//    
//    self.managerTab = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, self.view.width, self.view.height-50) style:UITableViewStylePlain];
//    _managerTab.delegate = self;
//    _managerTab.dataSource = self;
//    [self.view addSubview:_managerTab];
//    
//    [self setExtraCellLineHidden:_managerTab];
//    //cell分割线顶头
//    if ([self.managerTab respondsToSelector:@selector(setSeparatorInset:)]) {
//        [self.managerTab setSeparatorInset: UIEdgeInsetsZero];
//    }
//    if ([self.managerTab respondsToSelector:@selector(setLayoutMargins:)]) {
//        [self.managerTab setLayoutMargins: UIEdgeInsetsZero];
//    }
//
//    
//    
//    UIButton * managerBtn = [UIButton buttonWithType:UIButtonTypeCustom];
//    managerBtn.frame = CGRectMake(0, self.view.height-50, self.view.width, 50);
//    [managerBtn setTitle:self.managerStr forState:UIControlStateNormal];
//    [managerBtn setTitleColor:JK_RED_COLOR forState:UIControlStateNormal];
//    [managerBtn addTarget:self action:@selector(managerAction) forControlEvents:UIControlEventTouchUpInside];
//    [self.view addSubview:managerBtn];
//    
//    UIView * lineView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, managerBtn.width, 1)];
//    lineView.backgroundColor = JK_HUISE_LINE_COLOR;
//    [managerBtn addSubview:lineView];
//    
//}
//
//- (void)setExtraCellLineHidden: (UITableView *)tableView
//{
//    UIView *view = [[UIView alloc]init];
//    view.backgroundColor = [UIColor clearColor];
//    [tableView setTableFooterView:view];
//}
//
////全选
//- (void)leftBtnAction
//{
//
//    if (self.selectAllBool) {           //全部取消
//        self.selectAllBool = NO;
//        [self.managerArr removeAllObjects];
//        [self.managerTab reloadData];
//    }else
//    {
//        self.selectAllBool = YES;           //全部选中
//        [self.managerArr removeAllObjects];
//        if ([self.managerStr isEqualToString:@"删除"]) {              //删除管理
//            if ([self.deleteTypeStr isEqualToString:@"finished"]) {
//                [self.managerArr addObjectsFromArray:self.finishedList];
//            }
//            if ([self.deleteTypeStr isEqualToString:@"downing"]) {
//                [self.managerArr addObjectsFromArray:self.downingList];
//            }
//
//        }
//        
//        if ([self.managerStr isEqualToString:@"下载"]) {      //下载管理
//            [self.managerArr addObjectsFromArray:self.dataArr];
//        }
//
//        [self.managerTab reloadData];
//    }
//    //全选
//}
//
////完成
//- (void)rightBtnAction
//{
//    [self.navigationController popViewControllerAnimated:YES];
//}
//
//- (void)managerAction
//{
//    if ([self.managerStr isEqualToString:@"删除"]) {
//        [self cellDownLoadActionIndex];
//
//    }
//    if ([self.managerStr isEqualToString:@"下载"]) {
//        [self cellDownLoadActionIndex];
//    }
//
//}
//
//#warning ---多选下载事件----
////多选下载事件
//- (void)cellDownLoadActionIndex
//{
//    if (self.managerArr.count == 0) {
//        return;
//    }else{
//        //多选下载
//        if ([self.managerStr isEqualToString:@"下载"]) {
//            MBProgressHUD *hud=[MBProgressHUD showHUDAddedTo:[TheHomeManager shareTheHomeManager].appDelete.window animated:YES];
//            hud.mode=MBProgressHUDModeText;//枚举类型不同的效果
//            
//            hud.labelText=@"下载已开始";
//            [self performSelector:@selector(hiddenMBAction) withObject:nil afterDelay:0.5];
//
//            //换系统方法循环
//            for (JKSongsMessStatus * status in self.managerArr) {
//                NSString * imageStr = nil;
//                if (status.image300.length > 0) {
//                    imageStr = status.image300;
//                }else{
//                    imageStr = status.image;
//                }
//                if (status.singerName.length==0) {
//                    status.singerName = @"";
//                }
//                if (status.album.length == 0) {
//                    status.album = @"";
//                }
//
//                [self willDownloadMusic:status.wma songName:status.MusicName singerName:status.singerName pic:imageStr pic300:imageStr pic1:imageStr zhuanjiName:status.album songTime:status.wma_time songID:status.songID nclassID:nil zhuanjiID:nil];
//            }
//        }
//        
//        
//        //管理删除
//        if ([self.managerStr isEqualToString:@"删除"]) {
//            if ([self.deleteTypeStr isEqualToString:@"finished"]) {
//                //删除已下载文件
//                for (JKFileModel * fileModel in self.managerArr) {
//                    [[FilesDownManage sharedFilesDownManage]  deleteFinishFile:fileModel];
//                    self.finishedList = [FilesDownManage sharedFilesDownManage].finishedlist;
////                    [self.managerTab reloadData];
//                }
//                [self reloadMessData];
//            }
//            
//            if ([self.deleteTypeStr isEqualToString:@"downing"]) {
//                //删除正在下载的文件
//                for (ASIHTTPRequest * request in self.managerArr) {
//                    if ([self.downingList containsObject:request]) {
//                        NSLog(@"包了个含");
//                        
//                    }
//                    FilesDownManage *filedownmanage = [FilesDownManage sharedFilesDownManage];
//                    [filedownmanage deleteRequest:request];
//
////                    JKFileModel *fileManager=[request.userInfo objectForKey:@"File"];
////                    for (ASIHTTPRequest * requestOther in self.downingList) {
////                        JKFileModel *fileManagerOther=[requestOther.userInfo objectForKey:@"File"];
////                        if ([fileManager.fileURL isEqualToString:fileManagerOther.fileURL]) {
////                            FilesDownManage *filedownmanage = [FilesDownManage sharedFilesDownManage];
////                            [filedownmanage deleteRequest:request];
////                            continue;
////                        }
////                    }
//
//                }
//                [self reloadMessData];
//            }
//            
//            [self.managerArr removeAllObjects];
//        }
//
//    }
//}
//
//- (void)willDownloadMusic:(NSString *)wmastr songName:(NSString *)nameStr singerName:(NSString *)singerName pic:(NSString *)pic pic300:(NSString *)pic300 pic1:(NSString *)pic1 zhuanjiName:(NSString *)zjName songTime:(NSString *)songTime songID:(NSString *)songID nclassID:(NSString *)nclassID zhuanjiID:(NSString *)zhaunjiID
//{
//    [[FilesDownManage sharedFilesDownManage] downFileUrl:wmastr filename:nameStr singerName:singerName pic:pic pic300:nil pic1:nil zhuanjiName:zjName songTime:songTime songID:songID nclassID:nclassID zhuanjiID:zhaunjiID filetarget:@"mp3"];
//    
////    UINavigationController * myDownLoadNav = [[UINavigationController alloc] initWithRootViewController:[MyDownLoadViewController shareJKDownVC]];
////    [self presentViewController:myDownLoadNav animated:YES completion:nil];
//    
//}
//
////隐藏提示
//-(void)hiddenMBAction
//{
//    [MBProgressHUD hideHUDForView:[TheHomeManager shareTheHomeManager].appDelete.window animated:YES];
//    [self performSelector:@selector(rightBtnAction) withObject:nil afterDelay:1.0];
////    [self rightBtnAction];
//}
//
//
//#pragma mark - tableView代理方法
//- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
//{
//    if ([self.managerStr isEqualToString:@"下载"]) {
//        return self.dataArr.count;
//    }
//    if ([self.managerStr isEqualToString:@"删除"]) {
//        if ([self.deleteTypeStr isEqualToString:@"finished"]) {
//            return self.finishedList.count;
//        }
//        if ([self.deleteTypeStr isEqualToString:@"downing"]) {
//            return self.downingList.count;
//        }
//
//    }
//    return 0;
//}
//
//- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
//{
//    return 50;
//}
//
//- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
//{
//    static NSString * cellStr = @"managerCell";
//    MoreManagerTableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:cellStr];
//    if (!cell) {
//        cell = [[MoreManagerTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellStr];
//        cell.width = self.view.width;
//        cell.height = 50;
//    }
//    cell.createStr = @"";
//    //下载管理
//    if ([self.managerStr isEqualToString:@"下载"]) {
//        JKSongsMessStatus * status = [self.dataArr objectAtIndex:indexPath.row];
//        cell.songNameLabel.text = status.MusicName;
//        cell.zjNameLabel.text = status.album;
//    }
//    
//    //删除管理
//    if ([self.managerStr isEqualToString:@"删除"]) {
//        if ([self.deleteTypeStr isEqualToString:@"finished"]) {
//            JKFileModel * fileModel = [self.finishedList objectAtIndex:indexPath.row];
//            cell.songNameLabel.text = fileModel.fileName;
//            cell.zjNameLabel.text = fileModel.zjname;
//            if ([self.managerArr containsObject:fileModel]) {
//                cell.selectImageView.image = [UIImage imageNamed:@"select_ok@3x.png"];
//            }
//        }
//        if ([self.deleteTypeStr isEqualToString:@"downing"]) {
//            ASIHTTPRequest *theRequest=[self.downingList objectAtIndex:indexPath.row];
//            JKFileModel *fileInfo=[theRequest.userInfo objectForKey:@"File"];
//            cell.songNameLabel.text = fileInfo.fileName;
//            cell.zjNameLabel.text = fileInfo.zjname;
//            for (ASIHTTPRequest * request in self.managerArr) {
//                JKFileModel *fileManager=[request.userInfo objectForKey:@"File"];
//                if ([fileInfo.fileURL isEqualToString:fileManager.fileURL]) {
//                    cell.selectImageView.image = [UIImage imageNamed:@"select_ok@3x.png"];
//                }
//            }
//        }
//
//    }
//
//    
//    if (self.selectAllBool) {
//        cell.selectImageView.image = [UIImage imageNamed:@"select_ok@3x.png"];
//    }
//    return cell;
//}
//
//- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
//{
//    [tableView deselectRowAtIndexPath:indexPath animated:YES];
//    
//    MoreManagerTableViewCell * cell = (MoreManagerTableViewCell *)[tableView cellForRowAtIndexPath:indexPath];
//    UIImage * selectYesImage = [UIImage imageNamed:@"select_ok@3x.png"];
//    UIImage * selectNoImage = [UIImage imageNamed:@"select_no@3x.png"];
//    
//    if ([cell.selectImageView.image isEqual:selectNoImage]) {
//        cell.selectImageView.image = [UIImage imageNamed:@"select_ok@3x.png"];
//        //添加数据
//        if ([self.managerStr isEqualToString:@"下载"]) {
//            JKSongsMessStatus * status = [self.dataArr objectAtIndex:indexPath.row];
//            [self.managerArr addObject:status];
//        }
//        if ([self.managerStr isEqualToString:@"删除"]) {
//            if ([self.deleteTypeStr isEqualToString:@"finished"]) {
//                [self.managerArr addObject:[self.finishedList objectAtIndex:indexPath.row]];
//            }
//            if ([self.deleteTypeStr isEqualToString:@"downing"]) {
//                [self.managerArr addObject:[self.downingList objectAtIndex:indexPath.row]];
//            }
//        }
//
//        return;
//        
//    }
//    if ([cell.selectImageView.image isEqual:selectYesImage]) {
//        cell.selectImageView.image = [UIImage imageNamed:@"select_no@3x.png"];
//        //删除数据
//        if ([self.managerStr isEqualToString:@"下载"]) {
//            JKSongsMessStatus * status = [self.dataArr objectAtIndex:indexPath.row];
//            [self.managerArr removeObject:status];
//        }
//        if ([self.managerStr isEqualToString:@"删除"]) {
//            if ([self.deleteTypeStr isEqualToString:@"finished"]) {
//                [self.managerArr removeObject:[self.finishedList objectAtIndex:indexPath.row]];
//            }
//            if ([self.deleteTypeStr isEqualToString:@"downing"]) {
//                [self.managerArr removeObject:[self.downingList objectAtIndex:indexPath.row]];
//            }
//
//        }
//
//        return;
//
//        
//    }
//
//    
//    
//}
//
//- (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath{
//    if ([cell respondsToSelector:@selector(setSeparatorInset:)]) {
//        
//        [cell setSeparatorInset:UIEdgeInsetsZero];
//        
//    }
//    
//    if ([cell respondsToSelector:@selector(setLayoutMargins:)]) {
//        
//        [cell setLayoutMargins:UIEdgeInsetsZero];
//    }
//}
//
//
//#pragma mark - 通知刷新
//- (void)reloadMessData
//{
//    if ([self.managerStr isEqualToString:@"删除"]) {
//        FilesDownManage *filedownmanage = [FilesDownManage sharedFilesDownManage];
//        
//        self.downingList=filedownmanage.downinglist;
//        
//        self.finishedList=filedownmanage.finishedlist;
//        
//        NSLog(@"管理数 ========== %ld", self.managerArr.count);
//        
//        [self.managerTab reloadData];
//    }
//
//}
//
//- (void)dealloc
//{
//    [[NSNotificationCenter defaultCenter] removeObserver:self name:@"MoreManager" object:nil];
//}
//
//
//#pragma mark - 懒加载
//- (NSMutableArray *)managerArr
//{
//    if (_managerArr == nil) {
//        self.managerArr = [NSMutableArray array];
//    }
//    return _managerArr;
//}
//
//- (NSMutableArray *)finishedList
//{
//    if(_finishedList == nil){
//        self.finishedList = [NSMutableArray arrayWithCapacity:1];
//    }
//    return _finishedList;
//}
//
//- (NSMutableArray *)downingList
//{
//    if (_downingList == nil) {
//        self.downingList = [NSMutableArray array];
//    }
//    return _downingList;
//}
//
//
///*
//#pragma mark - Navigation
//
//// In a storyboard-based application, you will often want to do a little preparation before navigation
//- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
//    // Get the new view controller using [segue destinationViewController].
//    // Pass the selected object to the new view controller.
//}
//*/
//
//@end
